\section{Architecture}
% ¿Deberíamos hacer un estudio rollo Prometeus de lo que tendríamos que hacer
% aquí?
Here we show possible architectures for the development of the Artificial
Opponent:
\begin{itemize}
	\item One single agent
	\item One agent per task
	\item One agent per unit
\end{itemize}

And finally we discuss to convenience of having a meta agent role (called ``The
General'') that coordinates and weights the actions of the agents.

\subsection{One single agent}

\subsubsection{Description \& Goals}

In the {\it One single agent} architecture, only one agent has the control of
all functionalities of the player that represents, and his goal is to stay alive
and try to destroy the opponent.

Therefore this agent must have multidisciplinary skills that allow him to be
adapted to the game and be able to respond and resolve the different game
situations.

\subsubsection{Communication}
As each player is only represented by an agent, there are no internal
communication, the communicating actors are the other players and the goal is to
create alliances, ask for help, etc.
					
If the other players are human players typical human-machine interaction
problems can occur.


\subsubsection{Organization}
In theory there are not a social structure between the players, they are only
warfare agents.  But it is possible to start the game in an alliance or create
it during the game.

In the same way, alliances may be broken at any time, if there are no more
interests in common, if an agent betrays his allies, etc.

\subsubsection{BDI}
\paragraph{Beliefs}
	\begin{itemize}
		\item The agent wins the war if his units are alone in the map
		\item The agent can build more units as more resources can be obtained 
		\item All the enemy units are hostile and they can kill the agent
			units
	\end{itemize}
\paragraph{Desires \& Intentions}
	\begin{itemize}
		\item Win the game
		\item Have a good balance of military units and resource extractor
			units, depending on the strength of opponents and the resources
			available
		\item Achieve that opponents have a bad balance
		\item Using military units to kill enemy units in an efficient way
			and to take control of resources, avoiding that opponents have
			access to the resources.
	\end{itemize}

\subsubsection{Cooperative}

As it is said before, this architecture makes sense as a multi-agent solution if
there is the option that players cooperate together, not only respecting the
rules of the game, but also creating alliances.


\subsection{One agent per task}

	\subsubsection{Description \& Goals}
In this type of architecture the player is represented by different
agents. Each agent is responsible of part of the decisions, for example
one is responsible of the economics, another of the defense, etc. Then there
is another thing to think about, if this agents are autonomous and have to deal
with the other Agents to get a consensus or we have to create another agent that 
will act as a coordinator/decision agent.
Different goals and subgoals have to be well defined because having different agents
as a representation of a unique player may end having conflicts in the decisions, to solve this 
a hierarchy on the agent importance of the decisions can be a good idea.
	\subsubsection{Communication}
In this case there is a need of internal communication. Is a good option to create a chief agent
that ask the different subagents to realize one action or another. Also a communication between 
players can be defined, to create alliances ask for help.
	\subsubsection{Organization}
The main problem in this scenario is to rank the different decisions of the different agents. Here 
are two possibilities, to have a rank of importance of the agent predefined (for example military is more important
than economy) or to have an agent that will decide if there is a conflict between the decisions. 
	\subsubsection{BDI}
	\paragraph{Beliefs }
Each agent has its own believes(I.e. Domestic agent can believe they need more
mineral, military agent believes that must attack always that is able to). But
there is the possibility that they won't know the believes of other agents, also
it may decide to not take into account other agents believes. 
	\paragraph{Desires \& Intentions}
Each agent has its own desires. For example, domestic agent desire to keep the
maximum possible number of collectors or have the intention of having always a
surplus of mineral; and the military agent's desire is to always have the maximum number
of soldiers, vanish other players, do not leave its own base unprotected, or
minimize own loses and maximize enemy loses). 
	\subsubsection{Cooperative}
Like the previous architecture, it is possible to define the possibility of creating coalitions apart from having only the internal communication.
\subsection{One agent per unit}
\subsubsection{Description \& Goals}
In this architecture each unit in the game has its own controlling agent. This
design allows maximum decoupling of behaviours but also imposes new design
challenges. Now, the agent roles are created based on the unit type, extending
the metaphor also to buildings to provide them with its own autonomy.

Like the other architectures, the goal of each agent is to stay alive and to try
to destroy the opponent maximizing economic and military power as a subgoal to
achieve the main one.

\subsubsection{Communication}
Now that each agent has its own agent, communication poses a real challenge.
These games usually have hundreds of units in play simultaneously so we are
faced with a challenge that can involve the order of $N^2$ possible
communication acts. With the multiplicity of roles and tasks to perform special
consideration has the fact that special messages should be routed to the
specialized agent that can process it.

This setting raises some problems that should be addressed in the design phase
of the architecture. For instance, coordination could be a problem when massive
number of units are involved. How a squad is formed, a coordinated attack is
created, and actions like those are difficult to perform when there is no clear
leader. 

Another problem related to communication between the agents is related to the
broadcast of messages. Not all the agents are interested on each message
generated by the platform. Mechanism to route messages and to control that the
message channel don't become the bottleneck are required.

\subsubsection{Organization}
This scenario has only one goal. Defeat the opponent. All the other goals and
subgoals are subordinated to this one. In addition, the high number of agents
that must be coordinated demands some kind of abstractions in the organization
level. For this architecture we believe that the best organization is to have a
hierarchical one intended to coordinate all the units to the main goal. 

This hierarchical structure can also solve the communication problems stated
previously. All the communication of a given importance can be circumscribed to
a given level in the hierarchy. When messages must be routed to other agents
there is a well predefined routing channel through the hierarchy.

\subsubsection{BDI}
\paragraph{Beliefs}
Each agent will have different believes of the world based on the
role they perform. This role comes from the type of unit the agent is
governing. But anyway, all the units share the believe that all the enemy units
are hostile and that they try to kill you.

\paragraph{Desires \& Intentions}
Here we could distinguish between economic and military units. 
\begin{itemize}
	\item Economic units always want to create buildings and structures that
		maximize economic or military throughput. They know the tech tree of its
		faction and their plans will involve those that with minimum cost
		(building expenditure, research, etc.)
	\item Military units always want to destroy as much enemy units as possible,
		creating plans to attack given positions, ambushing the enemy or asking
		for help when in inferiority or when the enemy is taken by surprise.
\end{itemize}
Those units will have to negotiate somehow because most of the time they have
conflicting goals. It's the classical setup of ``cannons or butter'', only expanding
the economy can leave the player without defenses and be defeated by the
opponent, but too much military development could leave you underdeveloped and
exposed again to defeat.

%\paragraph{Intentions}
%Here intentions are the concrete realisation of the agents' desires, so it
%follows that intentions can be differentiated also between economic and
%military.
%\begin{itemize}
%	\item Economic units know the tech tree of its faction and their plans will
%		involve those that with minimum cost (building expenditure, research,
%		etc.) gives the player the most economic throughput.
%	\item Military unit will concrete their desires creating plans to attack
%		given positions, ambushing the enemy or asking for help when in
%		inferiority or when the enemy is taken by surprise.
%\end{itemize}

\subsubsection{Cooperative}
With this architecture when playing cooperative games several problems arise:
\begin{itemize}
	\item The communication worsens. If there are $k$ players and a media of
		$N$ units we could have $(kN)^2$ possible communication channels. 
	\item Coordination and leadership worsens too. Who leads, how to create
		coalitions, timing, etc\ldots are open problems.
	\item Trading resources could be addressed by the economic units.
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The General
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{The General}
All the architectures exposed so far could benefit from an agent role called
\emph{The General}. It represents the ultimate goal that is to win the game and
so its responsibilities are to balance resources, to route messages, to provide
arbitrage in negotiation, etc.
